package org.holynite.TiebarSpiderFx.Main

import configuration.ApplicationContextConfiguration
import javafx.application.Application
import javafx.scene.Parent
import javafx.scene.Scene
import javafx.stage.Stage
import org.holynite.TiebarSpiderFx.Beans.AppDefinations
import org.springframework.context.ApplicationContext
import utils.LogFactory

import java.util.logging.Logger

/**
 * Created by midnite on 14/11/27.
 */
class AppLauncher extends Application {

	static final ApplicationContext ctx = ApplicationContextConfiguration.getAppContext()
	static final Logger log = LogFactory.getLogger(AppLauncher)

	@Override
	void start(Stage stage) throws Exception {
		AppDefinations appDef = ctx.getBean("defaults", AppDefinations)
		def loader = ctx.getBean(SPFxmlLoader)
		log.finer("Min Width: ${appDef.minWidth}; Min Height: ${appDef.minHeight}")

		loader.LoadScene("/fxml/main.fxml", "/css/main.css", appDef.minWidth, appDef.minHeight, stage)

		stage.title = appDef.appTitle
		stage.show();
	}

	static void main(String[] args) {
		ApplicationContextConfiguration.InitContext()
		launch(AppLauncher, args)
	}
}
